﻿using System;
using ProgressViewed;

namespace Progress
{
    public sealed class ProgressModel : ProgressModelbase
    {
        private bool disposed;


        public ProgressModel (string title)
        {
            this.Title = title;
        }


        protected override void Dispose (bool disposing)
        {
            if (! disposed)
            {
                base.Dispose (disposing);
                disposed = true;
            }
        }


        public string Caption
        { set { View.SetText (value); } }


        public void Dismiss ()
        { View.Close(); }


        public void SetMeter (int percent)
        { View.SetMeter (percent); }


        public ProgressResult Show ()
        {
            if (View == null)
                return ProgressResult.TaskComplete;

            ProgressResult result = View.ShowModal ();
            return result;
        }
    }
}
